<template>
	<view class="bgw">
		<view class="flex">
			<view class="flex-1" :class="v.auth?'':'unAuth'" v-for="v in menus" @click="bindTap(v)">
				<view class="blank30"></view>
				<view class="blank10"></view>
				<image class="menu-icon" :src="v.icon" mode="aspectFit"></image>
				<view class="blank20"></view>
				<view class="text-center">
					{{ v.title }}
				</view>
				<view class="blank30"></view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				menus: [{
						title: "入库",
						icon: "/static/images/stock1.png",
						url: "/warehousing/warehousing",
					},
					{
						title: "出库",
						icon: "/static/images/stock2.png",
						url: "/stockOut/stockOut"
					},
					{
						title: "盘点",
						icon: "/static/images/stock3.png",
						url: "/inventory/inventory"
					},
				],
				role:{},
				stockAuth:{}
			};
		},
		created() {
			try{
				this.role = this.$store.getters.get_role;
				let stockAuth = this.role['仓管模块'];
				// console.log(stockAuth);
				// stockAuth['出库'].write = false;
				this.menus.forEach((v,i)=>{
					if(v.title=='出库'){
						this.menus[i].auth = stockAuth['出库'].write || stockAuth['出库申请'].write;
					}else{
						this.menus[i].auth = stockAuth[v.title].write;
					}
				})
			}catch(e){
				
			}
		},
		methods:{
			bindTap(v){
				if(v.auth){
					this.nav(v.url);
				}else{
					uni.$u.toast("无权限");
				}
			}
		}
	};
</script>
<style lang="scss" scoped>
	.menu-icon {
		display: block;
		width: 66upx;
		height: 66upx;
		margin: 0 auto;
	}
	.unAuth{
		opacity: 0.5;
	}
</style>